import { viteMockServe } from 'vite-plugin-mock'
import metadata from './metadata'
import getMenuList  , { menuApis } from './menu'
import { userApis } from './user'
import { customerApis } from './customer'

// 合并所有API
const allApis = [
  ...metadata,
  ...menuApis,
  ...userApis,
  ...customerApis
]

// 生产环境mock服务器设置
export function setupProdMockServer() {
  console.log('设置生产环境Mock服务器...')
  return allApis
}

// 开发环境mock插件配置
export function setupMockPlugins(isBuild) {
  return viteMockServe({
    mockPath: 'mock',
    localEnabled: true,
    logger: true,
    supportTs: false,
    injectCode: `
      import { setupProdMockServer } from '@/mock';
      setupProdMockServer();
    `
  })
}

console.log('Mock API已配置:', {
  apiCount: allApis.length,
  menuApis: menuApis.length,
  userApis: userApis.length,
  customerApis: customerApis.length
})

export default allApis